package HomeWork;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import demo04.Player;

public class DoDiZhu {
    public static void main(String[] args) {
        // 准备牌
        ArrayList<String> poker = new ArrayList<>();
        Collections.addAll(poker, "0-大王","1-小王","2-♥2","3-♣2","4-♦2","5-♠2","6-♥A","7-♣A","8-♦A","9-♠A",
                "10-♥K","11-♣K","12-♦K","13-♠K","14-♥Q","15-♣Q","16-♦Q","17-♠Q","18-♥J","19-♣J","20-♦J","21-♠J","22-♥10","23-♣10","24-♦10","25-♠10","26-♥9","27-♣9","28-♦9","29-♠9",
                "30-♥8","31-♣8","32-♦8","33-♠8","34-♥7","35-♣7","36-♦7","37-♠7","38-♥6","39-♣6","40-♦6","41-♠6","42-♥5","43-♣5","44-♦5","45-♠5","46-♥4","47-♣4","48-♦4","49-♠4",
                "50-♥3","51-♣3","52-♦3","53-♠3");

        // 洗牌,打乱顺序
        Collections.shuffle(poker);

        HashMap<Integer, ArrayList<String>> map = new HashMap<>();
        map.put(1, new ArrayList<>());
        map.put(2, new ArrayList<>());
        map.put(3, new ArrayList<>());

        // 三人交替摸牌，每人17张
        for (int i = 0; i < poker.size(); i++) {
            String p = poker.get(i);
            if (i >= 51) {
                map.get(1).add(p);
            } else if (i % 3 == 0) {
                map.get(1).add(p);
            } else if (i % 2 == 0) {
                map.get(2).add(p);
            } else if (i % 1 == 0) {
                map.get(3).add(p);
            }
        }

        // 对每个人得到的牌进行排序
        Collections.sort(map.get(1));
        Collections.sort(map.get(2));
        Collections.sort(map.get(3));

        System.out.println("老王:" + map.get(1));
        System.out.println("老李:" + map.get(2));
        System.out.println("隔壁老王:" + map.get(3));
    }
}
